package test;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

/**
 * @author szpc-01
 * @title: AbsIntegerEncoder
 * @projectName netty
 * @description: TODO
 * @date 2019/4/1013:58
 */
public class AbsIntegerEncoder extends MessageToMessageEncoder<ByteBuf> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
                while(byteBuf.readableBytes()>=4){
                    int value=Math.abs(byteBuf.readInt());
                    list.add(value);
                }
    }
}
